<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
        <div id="app">
            <input type="text" v-model="content" @keydown.enter="add">
            <ul>
               
                <li v-for="(item,index) in hhh">
                    {{item.name}}

                    <button @click="dele(item.index)">删除</button>
                </li>
                
            </ul>
        </div>
        
        <script src="vue.js"></script>
        <script>
            var app=new Vue({
                el:"#app",
                data:{
                   hhh:[
                       {id:0,name:'吃饭'},
                       {id:1,name:'睡觉'},
                       {id:2,name:'打豆豆'}
                   ],
                  
                    content:'',
                },
                methods:{
                        dele(index){
                           this.hhh.splice(index,1);
                        },
                        add(){
                            this.hhh.unshift({
                                // +new Date() 毫秒数
                                id:+new Date(),
                                name:this.content
                            });
                            // console.log(this.aaa.name);
                        }
                }
 
            })
        </script>
</body>
</html>